import collections

OGLogRequest = collections.namedtuple('OGLogRequest', [
    'machine',
    'owner',
    'exchange',
    'market_type',
],
                                      verbose=False)


def create_og_log_request(machine, owner, exchange, market_type):
  assert machine is not None
  assert owner is not None
  assert exchange is not None
  assert market_type in ("Spot", "Margin", "Futures"), market_type

  return OGLogRequest(machine, owner, exchange, market_type)


def expand_og_log_request(og_log_request):
  result = []
  for info in og_log_request:
    machine = info['machine']
    owner = info['owner']
    exchange = info["exchange"]
    market_type = info['market_type']
    result.append(
        OGLogRequest(machine=machine, owner=owner, exchange=exchange, market_type=market_type))
  return result


def expand_og_log_request_sample():
  og_log_request = [
      {
          'exchange': 'Bitfinex',
          'market_type': 'Margin',
          'machine': 'strategy-09.aliyun-cn-hongkong',
          'owner': 'jshin0'
      },
      {
          'exchange': 'Huobi',
          'market_type': 'Spot',
          'machine': 'strategy-05.aliyun-cn-hongkong',
          'owner': 'jshin2'
      },
  ]

  return (expand_og_log_request(og_log_request))
